﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;

/// <summary>
/// extension methods for Page
/// </summary>
public static class PageExt
{
    public static void RenderV<T>(this PageBase p, string viewName, bool verifyRenderingInForm, Action<T> act) 
    where T:Control
    {
        var v = string.Format("~/views/{0}.ascx",viewName);
        var vm = new SystemX.Web.ViewManager<T>(v,null,verifyRenderingInForm);
        act(vm.Control);
        if (verifyRenderingInForm) {
            p.HtmlWriter.Write(vm.Render());
        }
        else
        {
            vm.Control.RenderControl(p.HtmlWriter);
        }
    }
}
